<template>
  <div>
    <el-table v-loading="loading" :data="noticeList">
      <el-table-column label="序号" align="center" prop="order" width="50" />
      <el-table-column label="接收者" align="center" min-width="150">
        <template slot-scope="scope">
          {{ scope.row.count || '-' }}<template v-if="scope.row.count !== '全部用户'">位</template>
          | <el-link type="primary" @click="handleUpdate(scope.row)">查看</el-link>
        </template>
      </el-table-column>
      <el-table-column label="消息内容" align="center" min-width="200" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.content || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="发送状态" align="center" min-width="120">
        <template slot-scope="scope">
          <dict-tag :options="MessageStatus" :value="scope.row.status" />
        </template>
      </el-table-column>
      <el-table-column label="发送时间" align="center" min-width="120">
        <template slot-scope="scope">
          {{ scope.row.createTime || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="发送者" align="center" min-width="120">
        <template slot-scope="scope">
          {{ scope.row.createBy || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="创建部门" align="center" min-width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.deptName || '-' }}
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
    <!-- 编辑广告 -->
    <template v-if="open">
      <ListNumber :rowObj="rowObj"></ListNumber>
    </template>
  </div>
</template>

<script>
import { getmessagelist } from "@/api/system/message.js";
export default {
  // dicts: ['sys_notice_status', 'sys_notice_type'],
  components: {
    ListNumber: () => import('../form/ListNumber.vue')//清单
  },
  data () {
    return {
      ImageOpen: false,
      ImageSrc: '',
      // 遮罩层
      loading: true,
      opendetailed: false,
      detailedObj: {},
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      dictdatalist: [],
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 弹出层表格数据
      noticeList: [],
      rowObj: {},
      // 弹出层标题
      title: "修改广告",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderByColumn: 'messageId',
        isAsc: 'desc'//倒叙
      },
      // 表单参数
      form: {
        sort: 1,
        advId: undefined
      },
      // 表单校验
      rules: {
        sort: [
          { required: true, message: "必填", trigger: "change" }
        ],
      }
    };
  },
  watch: {
  },
  created () {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    async getList (value) {
      this.loading = true;
      let obj = value || {}
      let params = {
        ...this.queryParams,
        ...obj
      }
      getmessagelist(params).then(response => {
        this.noticeList = response.rows && response.rows.map((item, index) => {
          return {
            ...item,
            order: index + 1
          }
        });
        this.total = response.total;
        this.loading = false;
      });
    },
    // 打开详细弹窗
    handledetailed (row) {

    },
    /** 生成按钮操作 */
    handleSelect (row) {
      this.$confirm(`是否确认生成盘点任务`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.loading = true;
        let params = row.planId
        putTaskGen(params).then(res => {
          if (res.code === 200) {
            this.$message.success(res.msg)
            this.getList()
          }
          this.loading = false;
        }).catch(() => { this.loading = false; });
      }).catch(() => { })
    },
    handleUpdate (row) {//编辑
      this.rowObj = row
      this.open = true
      // this.$emit('handleUpdate', row.planId)
    },
    // 多选框选中数据
    handleSelectionChange (selection) {
      this.ids = selection.map(item => item.noticeId)
      this.single = selection.length != 1
      this.multiple = !selection.length
    },
  },
  filters: {
  }
};
</script>
<style lang="scss" scoped>
.red {
  color: red;
}

.el-input-number--medium {
  width: 134px;
}
</style>